package com.example.thread;


/**
 * @author Administrator
 * 死锁案例
 */
public class DeadLock {
    public static void main(String[] args) {
        new Thread(() -> {
            try {
                synchronized (DeadLock.class) {
                    Thread.sleep(1000);
                    synchronized (Object.class) {
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }).start();
        new Thread(() -> {
            try {
                synchronized (Object.class) {
                    Thread.sleep(1000);
                    synchronized (DeadLock.class) {
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }).start();
    }
}
